<template>
  <div class="home-album">
    <h3>全部新碟</h3>
    <div class="wrapper" ref="wrapper">      
      <ul class="content" ref="content">
        <li v-for="(item, index) in listData" :key="index" >  <!--  @click="selectItem(item)" -->
          <div class="cover">
            <van-image :src="item.blurPicUrl" radius="1rem" />
          </div>
          <span>{{ item.name }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { betterScrollHorizontal } from "../../common/betterScroll.js"; //引入betterscroll
export default {
  data() {
    return {
      listData: [],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.$request("get", "/album/new").then((res) => {
        console.log(res);
        if (res.code == 200) {
          this.listData = res.albums
          // let data = res.monthData;
          // console.log(data)
          // for(let i=0;i<data.length;i++){
          //     //console.log(data[i])
          //     this.listData = data
          // }     
          console.log(this.listData);   
        }
        
        // 异步数据的一些处理

        betterScrollHorizontal(
          this,
          this.$refs.wrapper,
          this.$refs.content,
          this.listData.length,
          10
        );
      });
    },
    // selectItem(item){
    //   const singermid = item.id; //获取歌单id
    //   this.$store.dispatch('saveSinger', item)
    //   this.$router.push({path:`/singer/${singermid}`})
    // }
  },
};
</script>
<style scoped>
.cover > span {
  position: absolute;
  right: 0.2rem;
  bottom: 0.4rem;
  background-color: #a6a0a0;
  color: white;
  font-size: 14px;
  width: 5rem;
  display: inline-block;
  border-radius: 1rem;
}
.cover {
  position: relative;
}
.wrapper {
  width: 100%; /*容器的宽度就是屏幕的宽度*/
  overflow: hidden;
}
ul.content li {
  /**1i默认是块级元素，修改为行内元素，但是要具备块级元素的特性*/
  display: inline-block;
  width: 10rem;
  vertical-align: top; /*垂直方向的位置*/
}
/*11里面有两个元素: div和span,所以使用通配符*/

ul.content li * {
  margin: 0.1rem; /**11里面有两个元素: div和span,所以使用通配符*/
}
ul.content li > span {
  font-size: 0.8rem;
  color: #54493b;
}
</style>